home *** CD-ROM | disk | FTP | other *** search
- =======================================================================
- The datespan program DATESPAN is a stand alone application that may be
- called from HLL programs to perform span calculations.
-
- A command interface is provided to DATESPAN. The CPP is named
- DATESPAN1. The command is named DATESPAN.
-
- Use of the DATESPAN stand-alone program is explained below.
- =======================================================================
- PROGRAM NAME: DATESPAN
- PROGRAM TYPE: CLP
-
- PURPOSE: Determine the number of days between two dates.
-
- PARAMETERS: DATE1 (MMDDYY)
- DATE2 (MMDDYY)
- SPANTYPE (1,-1,0) Default(0)
- DAYS Return Variable
- FLAG Return Variable
-
- PARAMETER
- ATTRIBUTES: DATE1 TYPE(*DEC) LEN(6 0)
- DATE2 TYPE(*DEC) LEN(6 0)
- SPANTYPE TYPE(*DEC) LEN(1 0)
- DAYS TYPE(*DEC) LEN(6 0)
- FLAG TYPE(*CHAR) LEN(1)
-
- PROGRAM DESCRIPTION:
-
- Datespan will return the number of days between any two 20th
- century dates.
-
- The date parameters are numeric and are in month/day/year format.
-
- The spantype parameter determines the inclusion or exclusion of
- the date parameters when the span is calculated. To illustrate the use
- of the spantype parameter assume the following dates: 01/01/87 and
- 01/02/87.
-
- A spantype of 0 is the most commonly requested spantype. Spantype
- 0 returns the number of ELAPSED days between two dates. Using the dates
- discussed above, the value returned in the DAYS variable for a spantype
- of 0 will be a ONE. Spantype 0 is the default spantype if an invalid
- spantype is passed to the program.
-
- If the spantype parameter is 1, then both dates are used when
- calculating the span of days between the dates. The value placed in the
- DAYS return variable will be a TWO.
-
- A spantype of -1 returns the number of days between the date
- parameters, but does not include either date in the span calculation.
- The value returned in the DAYS variable for a spantype of -1, using the
- above dates, would be ZERO.
-
- The FLAG parameter is used to notify the calling program that an
- error occurred during execution of DATESPAN. DATESPAN validates the
- dates passed to it. If either date is invalid DATESPAN returns a '*' in
- the FLAG variable. If no error occurs, FLAG contains a blank.
-
- =======================================================================
-
- * ================== *
- * RPG CODING EXAMPLE *
- * ================== *
- C*
- C DATSPN PLIST DATE SPAN PGM.
- C PARM MDY1 60 DATE1
- C PARM MDY2 60 DATE2
- C PARM +0 SPNTYP 10 SPAN TYPE
- C PARM DAYSPN 60 NUMBER OF DAYS
- C PARM ' ' FLAG 1 RETURN CODE.
- C*
- C DSCHDT MULT +100.0001 MDY1 CALC DIFF BTWN
- C DRDYDT MULT +100.0001 MDY2 SCHEDULED DATE
- C* AND READY DATE.
- C CALL 'DATESPAN'DATSPN GET DATE SPAN.
- C FLAG IFEQ ' ' IF NO ERROR SET
- C Z-ADDDAYSPN DRDYEL DAYS EARLY/LATE
- C ELSE ELSE
- C Z-ADD*ZERO DRDYEL EARLY/LATE = 0.
- C END
- C*
- =======================================================================
-
- ============================================================